#include "include/low_power.h"
#include "include/lp_modem.h"

#include "bsp.h"
#include "bsp_modem.h"
#include "qlmodem/task_modem.h"

/**
 * @brief 休眠使能检测
 * @return 0 - 不能休眠, TASK_ALWAYS_SLEEP - 一直休眠, 其他数值: 可休眠的时间, unit: ms
 */
uint32_t modem_canstop(void)
{
    return qltask_modem_canstop()*1000;
}

/**
 * @brief 休眠前处理函数
 */
void modem_prestop(void)
{
    modem_uart_sleep();
}

/**
 * @brief 休眠唤醒后处理函数
 */
void modem_poststop(void)
{
    modem_uart_wakeup();
}

// 依赖工作模式和激活状态进行配置
sleep_item_t lp_modem = {
    .name       = "MODEM", 
    .canstop    = modem_canstop,
    .prestop    = modem_prestop,
    .poststop   = modem_poststop,
};